#ifndef _RAM_H_
#define _RAM_H_

#include "systemc.h"

#define M_BLOCKS 384
#define MEM_ADDR _m_addr.to_uint()
#define ADDR0    MEM_ADDR
#define ADDR1    (MEM_ADDR + 1)
#define ADDR2    (MEM_ADDR + 2)
#define ADDR3    (MEM_ADDR + 3)

class ram : sc_module
{
  sc_lv<32> _mem[M_BLOCKS];
  sc_lv<32> _m_addr; // memory address

public:
  sc_in< sc_logic >   cs;
  sc_in< sc_logic >   rw;

  sc_in< sc_lv<32> >  addr;
  sc_in< sc_lv<32> >  din0;
  sc_in< sc_lv<32> >  din1;
  sc_in< sc_lv<32> >  din2;
  sc_in< sc_lv<32> >  din3;

  sc_out< sc_logic >  rdy;
  sc_out< sc_lv<32> > dout0;
  sc_out< sc_lv<32> > dout1;
  sc_out< sc_lv<32> > dout2;
  sc_out< sc_lv<32> > dout3;

  SC_CTOR (ram) : _m_addr(0)
  {
    init();

    rdy.initialize(SC_LOGIC_1);
    dout0.initialize(0);
    dout1.initialize(0);
    dout2.initialize(0);
    dout3.initialize(0);

    SC_THREAD (compute);
    sensitive << cs << rw << addr 
              << din0 << din1 << din2 << din3;
  }

  void compute(void);
  void init(void);

};

#endif /* _RAM_H_ */
